<template>
  <div class="list" ref="wrapper">
    <div>
      <div class="area">
        <div class="title">您的位置</div>
        <div class="button-list">
          <div class="button-wrapper">
            <div class="button">{{ this.city }}</div>
          </div>
        </div>
      </div>
      <div class="area">
        <div class="title">热门城市</div>
        <div class="button-list">
          <div class="button-wrapper" v-for="item of hot" :key="item.id">
            <div class="button">{{ item.name }}</div>
          </div>
        </div>
      </div>
      <div class="area" v-for="(item, key) of cities" :key="key">
        <div class="title">{{ key }}</div>
        <div class="item-list">
          <div class="item border-bottom" v-for="innerItem of item" :key="innerItem.id">
            {{innerItem.name}}
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import BScroll from "better-scroll";
export default {
  name: "CityList",
  props: {
    city: String,
    cities: Object,
    hot: Array,
  },
  mounted() {
    this.scroll = new BScroll(this.$refs.wrapper);
  },
  updated() {
    this.scroll.refresh();
  },
};
</script>
<style scoped>
/* 这是将已经定义好的公用css改变样式 */
.border-bottom::before {
  border-color: #ccc;
}
.list {
  overflow: hidden;
  position: absolute;
  top: 78px;
  left: 0;
  bottom: 0;
  right: 0;
}
.title {
  height: 22px;
  line-height: 22px;
  padding-left: 10px;
  background: #eee;
  color: #666;
  border-bottom: 1px solid #ccc;
}
.button-list {
  overflow: hidden;
  padding: 5px 30px 5px 5px;
}
.button-wrapper {
  width: 33.33%;
  float: left;
}
.button {
  box-sizing: border-box;
  border: 2px solid #ccc;
  margin: 5px;
  padding: 5px 0;
  text-align: center;
  border-radius: 3px;
}
.item {
  padding-left: 10px;
  line-height: 40px;
}
</style>